<?php
class Cliente{
	private $id_cliente;
	private $rut;
	private $nombres;
	private $ape_paterno;
	private $ape_materno;
	private $fec_nacimiento;
	private $tel_particular;
	private $tel_comercial;
	private $tel_celular;
	private $email;
	private $id_estadocivil;
	private $id_regimen;
	private $id_renta;
	private $id_rentacodeudor;
	private $id_fincompra;
	private $id_medio;
	private $id_profesion;
	private $id_region;
	private $id_comuna;
	private $id_pie;
	private $id_expectativa;
	private $obs_criterios;
	private $obs_necesidades;
	private $obs_generales;
	private $direccion;
	private $id_categoria;
	private $nacionalidad;
	private $nombre_codeudor;
	private $rut_codeudor;
	
	public function getCliente($id_cliente) //como parametro recibe el ID de la sesion y recupera de la BDD los datos del cliente
	{
		require_once("../include/conec.php");
		$this->id_cliente = $id_cliente;
		$link = Conectarse();
		$result = mysql_query("SELECT * FROM clientes WHERE id = $this->id_cliente", $link);
		if($row=mysql_fetch_array($result)) 
		{
			$this->rut = $row['rut'];
			$this->nombres = $row['nombres'];
			$this->ape_paterno = $row['ape_paterno'];
			$this->ape_materno = $row['ape_materno'];
			$this->fec_nacimiento = date("d-m-Y",strtotime($row['fec_nacimiento']));
			$this->nacionalidad = $row['nacionalidad'];
			$this->direccion = $row['direccion'];
			$this->tel_particular = $row['tel_particular'];
			$this->tel_comercial = $row['tel_comercial'];
			$this->tel_celular = $row['tel_celular'];
			$this->email = $row['email'];
			$this->id_estadocivil = $row['id_estadocivil'];
			$this->id_regimen = $row['id_regimen'];
			$this->id_renta = $row['id_renta'];
			$this->rut_codeudor = $row['rut_codeudor'];
			$this->nombre_codeudor = $row['nombre_codeudor'];
			$this->id_rentacodeudor = $row['id_rentacodeudor'];
			$this->id_fincompra = $row['id_fincompra'];
			$this->id_medio = $row['id_medio'];
			$this->id_profesion = $row['id_profesion'];
			$this->id_region = $row['id_region'];
			$this->id_comuna = $row['id_comuna'];
			$this->id_pie = $row['id_pie'];
			$this->id_expectativa = $row['id_expectativa'];
			$this->obs_criterios = $row['obs_criterios'];
			$this->obs_necesidades = $row['obs_necesidades'];
			$this->obs_generales = $row['obs_generales'];
			$this->direccion = $row['direccion'];
			$this->id_categoria = $row['id_categoria'];
			$this->nacionalidad = $row['nacionalidad'];
			$this->nombre_codeudor = $row['nombre_codeudor'];
			$this->rut_codeudor = $row['rut_codeudor'];				
		}
		if($result!="")	mysql_free_result($result);
		mysql_close($link);
	}
	
	public function getClienteByRut($rut_cliente) //como parametro recibe el ID de la sesion y recupera de la BDD los datos del cliente
	{
		require_once("../include/conec.php");
		$this->rut = $rut_cliente;
		$link = Conectarse();
		$query = "SELECT * FROM clientes WHERE rut = '$this->rut'";
		$result = mysql_query($query, $link);
		if($row=mysql_fetch_array($result))
		{
			$this->id_cliente = $row['id'];
			$this->nombres = $row['nombres'];
			$this->ape_paterno = $row['ape_paterno'];
			$this->ape_materno = $row['ape_materno'];
			$this->fec_nacimiento = date("d-m-Y",strtotime($row['fec_nacimiento']));
			$this->nacionalidad = $row['nacionalidad'];
			$this->direccion = $row['direccion'];
			$this->tel_particular = $row['tel_particular'];
			$this->tel_comercial = $row['tel_comercial'];
			$this->tel_celular = $row['tel_celular'];
			$this->email = $row['email'];
			$this->id_estadocivil = $row['id_estadocivil'];
			$this->id_regimen = $row['id_regimen'];
			$this->id_renta = $row['id_renta'];
			$this->rut_codeudor = $row['rut_codeudor'];
			$this->nombre_codeudor = $row['nombre_codeudor'];
			$this->id_rentacodeudor = $row['id_rentacodeudor'];
			$this->id_fincompra = $row['id_fincompra'];
			$this->id_medio = $row['id_medio'];
			$this->id_profesion = $row['id_profesion'];
			$this->id_region = $row['id_region'];
			$this->id_comuna = $row['id_comuna'];
			$this->id_pie = $row['id_pie'];
			$this->id_expectativa = $row['id_expectativa'];
			$this->obs_criterios = $row['obs_criterios'];
			$this->obs_necesidades = $row['obs_necesidades'];
			$this->obs_generales = $row['obs_generales'];
			$this->direccion = $row['direccion'];
			$this->id_categoria = $row['id_categoria'];
			$this->nacionalidad = $row['nacionalidad'];
			$this->nombre_codeudor = $row['nombre_codeudor'];
			$this->rut_codeudor = $row['rut_codeudor'];
		}
		if($result!="")	mysql_free_result($result);
		mysql_close($link);
	}
	
	public function getRut()
	{
		return $this->rut;
	}
	public function getNombres()
	{
		return $this->nombres;
	}
	public function getApellidoPaterno()
	{
		return $this->ape_paterno;
	}
	public function getApellidoMaterno()
	{
		return $this->ape_materno;
	}
	public function getFechaNacimiento()
	{
		return $this->fec_nacimiento;
	}
	public function getTelefonoParticular()
	{
		return $this->tel_particular;
	}
	public function getTelefonoComercial()
	{
		return $this->tel_comercial;
	}
	public function getTelefonoCelular()
	{
		return $this->tel_celular;
	}
	public function getEmail()
	{
		return $this->email;
	}
	public function getIdEstadoCivil()
	{
		return $this->id_estadocivil;
	}
	public function getNombreEstadoCivil()
	{
		require_once("../include/conec.php");
		$id_estado_civil = $this->id_estadocivil;
		$nombre_estado_civil;
		$link = Conectarse();
		$query = "SELECT * FROM parametros WHERE tipo = 'ESTADOCIVIL' AND id_parametro = $id_estado_civil";
		$result = mysql_query($query, $link);
	
		if($row=mysql_fetch_array($result))
		{
			$nombre_estado_civil = $row['valor'];
		}
		return $nombre_estado_civil;
		unset($row);
		if($result!="")	mysql_free_result($result);
		mysql_close($link);
	}
	public function getIdRegimen()
	{
		return $this->id_regimen;
	}
	public function getNombreRegimen()
	{
		require_once("../include/conec.php");
		$nombre_regimen;
		$link = Conectarse();
		$query = "SELECT * FROM parametros WHERE tipo = 'REGIMENMATRIMONIAL' AND id_parametro = $this->id_regimen";
		$result = mysql_query($query, $link);
	
		if($row=mysql_fetch_array($result))
		{
			$nombre_regimen = $row['valor'];
		}
		return $nombre_regimen;
		unset($row);
		if($result!="")	mysql_free_result($result);
		mysql_close($link);
	}
	
	
	public function getIdRenta()
	{
		return $this->id_renta;
	}
	public function getIdRentaCodeudor()
	{
		return $this->id_rentacodeudor;
	}
	public function getIdFinalidad()
	{
		return $this->id_fincompra;
	}
	public function getIdMedio()
	{
		return $this->id_medio;
	}
	public function getIdProfesion()
	{
		return $this->id_profesion;
	}
	public function getNombreProfesion()
	{
		require_once("../include/conec.php");
		$id_profesion = $this->id_profesion;
		$nombre_profesion;
		$link = Conectarse();
		$query = "SELECT * FROM parametros WHERE tipo = 'PROFESION' AND id_parametro = $id_profesion";
		$result = mysql_query($query, $link);
		
		if($row=mysql_fetch_array($result))
		{
			$nombre_profesion = $row['valor'];
		}
		return $nombre_profesion;
		unset($row);
		if($result!="")	mysql_free_result($result);
		mysql_close($link);
		
	}
	public function getIdRegion()
	{
		return $this->id_region;
	}
	public function getIdComuna()
	{
		return $this->id_comuna;
	}
	public function getNombreComuna()
	{
	/*	require_once("../include/conec.php");
		$id_comuna = $this->id_comuna;
		$nombre_comuna;
		$link = Conectarse();
		$query = "SELECT * FROM parametros WHERE tipo = 'COMUNA' AND id_parametro = $id_comuna";
		$result = mysql_query($query, $link);
	
		if($row=mysql_fetch_array($result))
		{
			$nombre_comuna = $row['valor'];
		}
		
		unset($row);
		if($result!="")	mysql_free_result($result);
		mysql_close($link);*/
		return $nombre_comuna;
	}
	public function getIdPie()
	{
		return $this->id_pie;
	}
	public function getIdExpectativa()
	{
		return $this->id_expectativa;
	}
	public function getObsCriterios()
	{
		return $this->obs_criterios;
	}
	public function getObsNecesidades()
	{
		return $this->obs_necesidades;
	}
	public function getObsGenerales()
	{
		return $this->obs_generales;
	}
	public function getNacionalidad()
	{
		return $this->nacionalidad;
	}
	public function getDireccion()
	{
		return $this->direccion;
	}
	public function getIdCategoria()
	{
		return $this->id_categoria;
	}	
	public function getNombreCodeudor()
	{
		return $this->nombre_codeudor;
	}
	public function getRutCodeudor()
	{
		return $this->rut_codeudor;
	}
	
	
}
